﻿/* Author:
 *  Andrea Vandin
 */
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace TripLOAMobile.InternalEntities
{

    /// <summary>
    /// This class represents the fields of a new travel.
    /// </summary>
    public class InsertTravelInfo : TravelInfoContainer
    {
        private byte freeSeats;
        private DateTime DepartureDateTime;

        #region constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertTravelInfo"/> class.
        /// </summary>
        public InsertTravelInfo()
            : base()
        {
            Comment = "";
            areDepLatLongDefined = false;
            areDesLatLongDefined = false;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertTravelInfo"/> class.
        /// </summary>
        /// <param name="departureTime">The departure time.</param>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="freeSeats">The free seats.</param>
        public InsertTravelInfo(DateTime departureTime, bool smokerAccepted, double latDep, double longDep, double latDes, double longDes, string comment, byte freeSeats)
            :this(departureTime,smokerAccepted,latDep,longDep,latDes,longDes,comment)
        {
            this.FreeSeats = freeSeats;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertTravelInfo"/> class.
        /// </summary>
        /// <param name="departureTime">The departure time.</param>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="freeSeats">The free seats.</param>
        public InsertTravelInfo(DateTime departureTime, bool smokerAccepted, double latDep, double longDep, double latDes, double longDes, string comment, int freeSeats)
            : this(departureTime, smokerAccepted, latDep, longDep, latDes, longDes, comment)
        {
            this.setFreeSeats(freeSeats);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertTravelInfo"/> class.
        /// </summary>
        /// <param name="departureTime">The departure time.</param>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="freeSeats">The free seats.</param>
        public InsertTravelInfo(DateTime departureTime, bool smokerAccepted, double latDep, double longDep, double latDes, double longDes, string comment, decimal freeSeats)
            : this(departureTime, smokerAccepted, latDep, longDep, latDes, longDes, comment)
        {
            this.setFreeSeats(freeSeats);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertTravelInfo"/> class.
        /// </summary>
        /// <param name="departureTime">The departure time.</param>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        /// <param name="comment">The comment.</param>
        private InsertTravelInfo(DateTime departureTime, bool smokerAccepted, double latDep, double longDep, double latDes, double longDes, string comment)
            : base(smokerAccepted)
        {
            this.setAllLatLong(latDep, longDep, latDes, longDes);
            this.Comment = comment;
        }
        #endregion

        /// <summary>
        /// Gets or sets the veichle.
        /// </summary>
        /// <value>The veichle.</value>
        public WS_SoapLogin.VehicleTypes Veichle
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the vehicle ID.
        /// </summary>
        /// <value>The vehicle ID.</value>
        public int VehicleID
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the departure time.
        /// </summary>
        /// <value>The departure time.</value>
        public DateTime DepartureTime
        {
            get
            {
                return DepartureDateTime;
            }
            set
            {
                DepartureDateTime = value;
            }
        }

        /// <summary>
        /// Gets or sets the free seats.
        /// </summary>
        /// <value>The free seats.</value>
        public byte FreeSeats
        {
            get
            {
                return freeSeats;
            }
            set
            {
                freeSeats=value;
            }
        }

        /// <summary>
        /// Sets the number of free seats.
        /// </summary>
        /// <param name="n">The number of free seats.</param>
        /// <returns></returns>
        public bool setFreeSeats(int number)
        {
            try
            {
                FreeSeats = (byte)number;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// Sets the number of free seats.
        /// </summary>
        /// <param name="n">The n.</param>
        /// <returns></returns>
        public bool setFreeSeats(decimal n)
        {
            try
            {
                FreeSeats = (byte)n;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>The comment.</value>
        public string Comment
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the departure.
        /// </summary>
        /// <value>The departure.</value>
        public new string Departure
        {
            get
            {
                departure = departureFields.getReadableString();
                return departure;
            }
        }

        /// <summary>
        /// Gets the destination.
        /// </summary>
        /// <value>The destination.</value>
        public new string Destination
        {
            get
            {
                destination = destinationFields.getReadableString();
                return destination;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="InsertTravelInfo"/> is draft.
        /// </summary>
        /// <value><c>true</c> if draft; otherwise, <c>false</c>.</value>
        public bool Draft
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the max deviation.
        /// </summary>
        /// <value>The max deviation.</value>
        public float? MaxDeviation
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the estimated budget.
        /// </summary>
        /// <value>The estimated budget.</value>
        public decimal? EstimatedBudget
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the estimated time.
        /// </summary>
        /// <value>The estimated time.</value>
        public short? EstimatedTime
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether [license required].
        /// </summary>
        /// <value><c>true</c> if [license required]; otherwise, <c>false</c>.</value>
        public bool LicenseRequired
        {
            get;
            set;
        }
    }
}
